
#include "WindowSettings.h"

#include <iostream>
#include <cstring>

// --------------------------------------------------------------------------------------
WindowSettings::WindowSettings(void)
	: title("Baby Engine"), argc(0), argv(NULL), width(512), height(512)
{

}
// --------------------------------------------------------------------------------------
WindowSettings::~WindowSettings(void)
{

}
// --------------------------------------------------------------------------------------
WindowSettings::WindowSettings(const WindowSettings& rhs)
	: title(rhs.title),
		argv(rhs.argv),
		argc(rhs.argc),
		width(rhs.width),
		height(rhs.height)
{

}
// --------------------------------------------------------------------------------------
WindowSettings& WindowSettings::operator=(const WindowSettings& rhs)
{
	if( this != &rhs )
	{
		title = rhs.title;
		argv = rhs.argv;
		argc = rhs.argc;
		width = rhs.width;
		height = rhs.height;
	}

	return *this;
}
// --------------------------------------------------------------------------------------
bool WindowSettings::hasParameter( const char* paramName ) const
{
	for( int i = 0 ; i < argc ; ++i )
	{
		if( strcmp(argv[i], paramName) == 0 )
		{
			//std::cout << paramName << std::endl;
			return true;
		}
	}

	return false;
}
// --------------------------------------------------------------------------------------
std::string WindowSettings::getParameter( const char* paramName ) const
{
	for( int i = 1 ; i <(argc-1) ; i ++ )
	{
		//std::cout << "\t" << argv[i] << std::endl;
		if( (strcmp(argv[i], paramName) == 0 ) && (i+1) <= argc )
		{
			std::cout << paramName << " = " << argv[i+1] << std::endl;
			return std::string( argv[i+1] );
		}
	}

	//std::cout << paramName << " NOT FOUND \n";
	return std::string();
}


